home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume9 / uemacs3.8b / part02 < prev    next >
Encoding:
Internet Message Format  |  1987-05-04  |  49.1 KB

  1. Subject:  v09i034:  MicroEMACS, verison 3.8b, Part02/14
  2. Path: mirror!sources-request
  3. From: sources-request@mirror.TMC.COM
  4. Newsgroups: comp.sources.unix
  5. Message-ID: <2285@mirror.TMC.COM>
  6. Sender: rs@mirror.TMC.COM
  7. Approved: rs@mirror.TMC.COM
  8. Lines: 1890
  9.  
  10. Submitted by: ihnp4!itivax!duncan!lawrence (Daniel Lawrence)
  11. Mod.sources: Volume 9, Issue 34
  12. Archive-name: uemacs3.8b/Part02
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line,
  16. # then unpack it by saving it in a file and typing "sh file".
  17. # If this archive is complete, you will see the message:
  18. #        "End of archive 2 (of 14)."
  19. # Contents:  crypt.c egapc.c emacs.key ibmpc.c region.c tipc.c vmsvt.c
  20. # Wrapped by rs@mirror on Fri Mar 13 13:23:23 1987
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. echo shar: Extracting \"crypt.c\" \(6931 characters\)
  23. if test -f crypt.c ; then 
  24.   echo shar: Will not over-write existing file \"crypt.c\"
  25. else
  26. sed "s/^X//" >crypt.c <<'END_OF_crypt.c'
  27. X/*    Crypt:    Encryption routines for MicroEMACS
  28. X        written by Dana Hoggatt and Daniel Lawrence
  29. X*/
  30. X
  31. X#include    <stdio.h>
  32. X#include    "estruct.h"
  33. X#include    "edef.h"
  34. X
  35. X#if    CRYPT
  36. X
  37. X#if    MEGAMAX & ST520
  38. Xoverlay    "crypt"
  39. X#endif
  40. X
  41. Xsetkey(f, n)    /* reset encryption key of current buffer */
  42. X
  43. Xint f;        /* default flag */
  44. Xint n;        /* numeric argument */
  45. X
  46. X{
  47. X    register int status;    /* return status */
  48. X    char key[NPAT];        /* new encryption string */
  49. X
  50. X    /* get the string to use as an encrytion string */
  51. X        if ((status = mlreply("Encryption String: ", key, NPAT - 1)) != TRUE)
  52. X                return(status);
  53. X
  54. X    /* and encrypt it */
  55. X    crypt((char *)NULL, 0);
  56. X    crypt(key, strlen(key));
  57. X
  58. X    /* and save it off */
  59. X    strcpy(curbp->b_key, key);
  60. X    mlwrite(" ");        /* clear it off the bottom line */
  61. X    return(TRUE);
  62. X}
  63. X
  64. X/**********
  65. X *
  66. X *    crypt - in place encryption/decryption of a buffer
  67. X *
  68. X *    (C) Copyright 1986, Dana L. Hoggatt
  69. X *    1216, Beck Lane, Lafayette, IN
  70. X *
  71. X *    When consulting directly with the author of this routine, 
  72. X *    please refer to this routine as the "DLH-POLY-86-B CIPHER".  
  73. X *
  74. X *    This routine was written for Dan Lawrence, for use in V3.8 of
  75. X *    MICRO-emacs, a public domain text/program editor.  
  76. X *
  77. X *    I kept the following goals in mind when preparing this function:
  78. X *
  79. X *        1.    All printable characters were to be encrypted back
  80. X *        into the printable range, control characters and
  81. X *        high-bit characters were to remain unaffected.  this
  82. X *        way, encrypted would still be just as cheap to 
  83. X *        transmit down a 7-bit data path as they were before.
  84. X *
  85. X *        2.    The encryption had to be portable.  The encrypted 
  86. X *        file from one computer should be able to be decrypted 
  87. X *        on another computer.
  88. X *
  89. X *        3.    The encryption had to be inexpensive, both in terms
  90. X *        of speed and space.
  91. X *
  92. X *        4.    The system needed to be secure against all but the
  93. X *        most determined of attackers.
  94. X *
  95. X *    For encryption of a block of data, one calls crypt passing 
  96. X *    a pointer to the data block and its length. The data block is 
  97. X *    encrypted in place, that is, the encrypted output overwrites 
  98. X *    the input.  Decryption is totally isomorphic, and is performed 
  99. X *    in the same manner by the same routine.  
  100. X *
  101. X *    Before using this routine for encrypting data, you are expected 
  102. X *    to specify an encryption key.  This key is an arbitrary string,
  103. X *    to be supplied by the user.  To set the key takes two calls to 
  104. X *    crypt().  First, you call 
  105. X *
  106. X *        crypt(NULL, vector)
  107. X *
  108. X *    This resets all internal control information.  Typically (and 
  109. X *    specifically in the case on MICRO-emacs) you would use a "vector" 
  110. X *    of 0.  Other values can be used to customize your editor to be 
  111. X *    "incompatable" with the normally distributed version.  For 
  112. X *    this purpose, the best results will be obtained by avoiding
  113. X *    multiples of 95.
  114. X *
  115. X *    Then, you "encrypt" your password by calling 
  116. X *
  117. X *        crypt(pass, strlen(pass))
  118. X *
  119. X *    where "pass" is your password string.  Crypt() will destroy 
  120. X *    the original copy of the password (it becomes encrypted), 
  121. X *    which is good.  You do not want someone on a multiuser system 
  122. X *    to peruse your memory space and bump into your password.  
  123. X *    Still, it is a better idea to erase the password buffer to 
  124. X *    defeat memory perusal by a more technical snooper.  
  125. X *
  126. X *    For the interest of cryptologists, at the heart of this 
  127. X *    function is a Beaufort Cipher.  The cipher alphabet is the 
  128. X *    range of printable characters (' ' to '~'), all "control" 
  129. X *    and "high-bit" characters are left unaltered.
  130. X *
  131. X *    The key is a variant autokey, derived from a wieghted sum 
  132. X *    of all the previous clear text and cipher text.  A counter 
  133. X *    is used as salt to obiterate any simple cyclic behavior 
  134. X *    from the clear text, and key feedback is used to assure 
  135. X *    that the entire message is based on the original key, 
  136. X *    preventing attacks on the last part of the message as if 
  137. X *    it were a pure autokey system.
  138. X *
  139. X *    Overall security of encrypted data depends upon three 
  140. X *    factors:  the fundamental cryptographic system must be 
  141. X *    difficult to compromise; exhaustive searching of the key 
  142. X *    space must be computationally expensive; keys and plaintext 
  143. X *    must remain out of sight.  This system satisfies this set
  144. X *    of conditions to within the degree desired for MicroEMACS.
  145. X *
  146. X *    Though direct methods of attack (against systems such as 
  147. X *    this) do exist, they are not well known and will consume 
  148. X *    considerable amounts of computing time.  An exhaustive
  149. X *    search requires over a billion investigations, on average.
  150. X *
  151. X *    The choice, entry, storage, manipulation, alteration, 
  152. X *    protection and security of the keys themselves are the 
  153. X *    responsiblity of the user.  
  154. X *
  155. X **********/
  156. X
  157. Xcrypt(bptr, len)
  158. Xregister char *bptr;    /* buffer of characters to be encrypted */
  159. Xregister unsigned len;    /* number of characters in the buffer */
  160. X{
  161. X    register int cc;    /* current character being considered */
  162. X
  163. X    static long key = 0;    /* 29 bit encipherment key */
  164. X    static int salt = 0;    /* salt to spice up key with */
  165. X
  166. X    if (!bptr) {        /* is there anything here to encrypt? */
  167. X        key = len;    /* set the new key */
  168. X        salt = len;    /* set the new salt */
  169. X        return;
  170. X    }
  171. X    while (len--) {        /* for every character in the buffer */
  172. X
  173. X        cc = *bptr;    /* get a character out of the buffer */
  174. X
  175. X        /* only encipher printable characters */
  176. X        if ((cc >= ' ') && (cc <= '~')) {
  177. X
  178. X/**  If the upper bit (bit 29) is set, feed it back into the key.  This 
  179. X    assures us that the starting key affects the entire message.  **/
  180. X
  181. X            key &= 0x1FFFFFFFL;    /* strip off overflow */
  182. X            if (key & 0x10000000L) {
  183. X                key ^= 0x0040A001L;    /* feedback */
  184. X            }
  185. X
  186. X/**  Down-bias the character, perform a Beaufort encipherment, and 
  187. X    up-bias the character again.  We want key to be positive 
  188. X    so that the left shift here will be more portable and the 
  189. X    mod95() faster   **/
  190. X
  191. X            cc = mod95((int)(key % 95) - (cc - ' ')) + ' ';
  192. X
  193. X/**  the salt will spice up the key a little bit, helping to obscure 
  194. X    any patterns in the clear text, particularly when all the 
  195. X    characters (or long sequences of them) are the same.  We do 
  196. X    not want the salt to go negative, or it will affect the key 
  197. X    too radically.  It is always a good idea to chop off cyclics 
  198. X    to prime values.  **/
  199. X
  200. X            if (++salt >= 20857) {    /* prime modulus */
  201. X                salt = 0;
  202. X            }
  203. X
  204. X/**  our autokey (a special case of the running key) is being 
  205. X    generated by a wieghted checksum of clear text, cipher 
  206. X    text, and salt.   **/
  207. X
  208. X            key = key + key + cc + *bptr + salt;
  209. X        }
  210. X        *bptr++ = cc;    /* put character back into buffer */
  211. X    }
  212. X    return;
  213. X}
  214. X
  215. X#if    MEGAMAX & ST520
  216. Xint mod95(val)
  217. X#else
  218. Xstatic int mod95(val)
  219. X#endif
  220. X
  221. Xregister int val;
  222. X
  223. X{
  224. X    /*  The mathematical MOD does not match the computer MOD  */
  225. X
  226. X    /*  Yes, what I do here may look strange, but it gets the
  227. X        job done, and portably at that.  */
  228. X
  229. X    while (val >= 9500)
  230. X        val -= 9500;
  231. X    while (val >= 950)
  232. X        val -= 950;
  233. X    while (val >= 95)
  234. X        val -= 95;
  235. X    while (val < 0)
  236. X        val += 95;
  237. X    return (val);
  238. X}
  239. X#else
  240. Xnocrypt()
  241. X{
  242. X}
  243. X#endif
  244. END_OF_crypt.c
  245. if test 6931 -ne `wc -c <crypt.c`; then
  246.     echo shar: \"crypt.c\" unpacked with wrong size!
  247. fi
  248. # end of overwriting check
  249. fi
  250. echo shar: Extracting \"egapc.c\" \(6871 characters\)
  251. if test -f egapc.c ; then 
  252.   echo shar: Will not over-write existing file \"egapc.c\"
  253. else
  254. sed "s/^X//" >egapc.c <<'END_OF_egapc.c'
  255. X/*
  256. X * The routines in this file provide support for the IBM-PC EGA and other
  257. X * compatible terminals. It goes directly to the graphics RAM to do
  258. X * screen output. It compiles into nothing if not an IBM-PC EGA driver
  259. X */
  260. X
  261. X#define    termdef    1            /* don't define "term" external */
  262. X
  263. X#include        <stdio.h>
  264. X#include    "estruct.h"
  265. X#include        "edef.h"
  266. X
  267. X#if     EGA
  268. X
  269. X#define NROW    43                      /* Screen size.                 */
  270. X#define NCOL    80                      /* Edit if you want to.         */
  271. X#define    MARGIN    8            /* size of minimim margin and    */
  272. X#define    SCRSIZ    64            /* scroll size for extended lines */
  273. X#define    NPAUSE    200            /* # times thru update to pause */
  274. X#define BEL     0x07                    /* BEL character.               */
  275. X#define ESC     0x1B                    /* ESC character.               */
  276. X#define    SPACE    32            /* space character        */
  277. X#define    SCADD    0xb8000000L        /* address of screen RAM    */
  278. X
  279. Xint *scptr[NROW];            /* pointer to screen lines    */
  280. Xint sline[NCOL];            /* screen line image        */
  281. X
  282. Xextern  int     ttopen();               /* Forward references.          */
  283. Xextern  int     ttgetc();
  284. Xextern  int     ttputc();
  285. Xextern  int     ttflush();
  286. Xextern  int     ttclose();
  287. Xextern    int    egakopen();
  288. Xextern    int    egakclose();
  289. Xextern  int     egamove();
  290. Xextern  int     egaeeol();
  291. Xextern  int     egaeeop();
  292. Xextern  int     egabeep();
  293. Xextern  int     egaopen();
  294. Xextern    int    egarev();
  295. Xextern    int    egacres();
  296. Xextern    int    egaclose();
  297. Xextern    int    egaputc();
  298. X
  299. X#if    COLOR
  300. Xextern    int    egafcol();
  301. Xextern    int    egabcol();
  302. X
  303. Xint    cfcolor = -1;        /* current forground color */
  304. Xint    cbcolor = -1;        /* current background color */
  305. Xint    ctrans[] =        /* ansi to ega color translation table */
  306. X    {0, 4, 2, 6, 1, 5, 3, 7};
  307. X#endif
  308. X
  309. X/*
  310. X * Standard terminal interface dispatch table. Most of the fields point into
  311. X * "termio" code.
  312. X */
  313. XTERM    term    = {
  314. X    NROW-1,
  315. X        NROW-1,
  316. X        NCOL,
  317. X        NCOL,
  318. X    MARGIN,
  319. X    SCRSIZ,
  320. X    NPAUSE,
  321. X        egaopen,
  322. X        egaclose,
  323. X    egakopen,
  324. X    egakclose,
  325. X        ttgetc,
  326. X    egaputc,
  327. X        ttflush,
  328. X        egamove,
  329. X        egaeeol,
  330. X        egaeeop,
  331. X        egabeep,
  332. X    egarev,
  333. X    egacres
  334. X#if    COLOR
  335. X    , egafcol,
  336. X    egabcol
  337. X#endif
  338. X};
  339. X
  340. Xextern union REGS rg;
  341. X
  342. X#if    COLOR
  343. Xegafcol(color)        /* set the current output color */
  344. X
  345. Xint color;    /* color to set */
  346. X
  347. X{
  348. X    cfcolor = ctrans[color];
  349. X}
  350. X
  351. Xegabcol(color)        /* set the current background color */
  352. X
  353. Xint color;    /* color to set */
  354. X
  355. X{
  356. X        cbcolor = ctrans[color];
  357. X}
  358. X#endif
  359. X
  360. Xegamove(row, col)
  361. X{
  362. X    rg.h.ah = 2;        /* set cursor position function code */
  363. X    rg.h.dl = col;
  364. X    rg.h.dh = row;
  365. X    rg.h.bh = 0;        /* set screen page number */
  366. X    int86(0x10, &rg, &rg);
  367. X}
  368. X
  369. Xegaeeol()    /* erase to the end of the line */
  370. X
  371. X{
  372. X    int attr;    /* attribute byte mask to place in RAM */
  373. X    int *lnptr;    /* pointer to the destination line */
  374. X    int i;
  375. X    int ccol;    /* current column cursor lives */
  376. X    int crow;    /*       row    */
  377. X
  378. X    /* find the current cursor position */
  379. X    rg.h.ah = 3;        /* read cursor position function code */
  380. X    rg.h.bh = 0;        /* current video page */
  381. X    int86(0x10, &rg, &rg);
  382. X    ccol = rg.h.dl;        /* record current column */
  383. X    crow = rg.h.dh;        /* and row */
  384. X
  385. X    /* build the attribute byte and setup the screen pointer */
  386. X#if    COLOR
  387. X    attr = (((cbcolor & 15) << 4) | (cfcolor & 15)) << 8;
  388. X#else
  389. X    attr = 0x0700;
  390. X#endif
  391. X    lnptr = &sline[0];
  392. X    for (i=0; i < NCOL; i++)
  393. X        *lnptr++ = SPACE | attr;
  394. X
  395. X    if (flickcode) {
  396. X        /* wait for vertical retrace to be off */
  397. X        while ((inp(0x3da) & 8))
  398. X            ;
  399. X
  400. X        /* and to be back on */
  401. X        while ((inp(0x3da) & 8) == 0)
  402. X            ;
  403. X    }
  404. X
  405. X    /* and send the string out */
  406. X    movmem(&sline[0], scptr[crow]+ccol, (NCOL-ccol)*2);
  407. X
  408. X}
  409. X
  410. Xegaputc(ch)    /* put a character at the current position in the
  411. X           current colors */
  412. X
  413. Xint ch;
  414. X
  415. X{
  416. X    rg.h.ah = 14;        /* write char to screen with current attrs */
  417. X    rg.h.al = ch;
  418. X#if    COLOR
  419. X    rg.h.bl = cfcolor;
  420. X#else
  421. X    rg.h.bl = 0x07;
  422. X#endif
  423. X    int86(0x10, &rg, &rg);
  424. X}
  425. X
  426. Xegaeeop()
  427. X{
  428. X    int attr;        /* attribute to fill screen with */
  429. X
  430. X    rg.h.ah = 6;        /* scroll page up function code */
  431. X    rg.h.al = 0;        /* # lines to scroll (clear it) */
  432. X    rg.x.cx = 0;        /* upper left corner of scroll */
  433. X    rg.x.dx = 0x2a4f;    /* lower right corner of scroll */
  434. X#if    COLOR
  435. X    attr = ((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15);
  436. X#else
  437. X    attr = 0;
  438. X#endif
  439. X    rg.h.bh = attr;
  440. X    int86(0x10, &rg, &rg);
  441. X}
  442. X
  443. Xegarev(state)        /* change reverse video state */
  444. X
  445. Xint state;    /* TRUE = reverse, FALSE = normal */
  446. X
  447. X{
  448. X    /* This never gets used under the ega-PC driver */
  449. X}
  450. X
  451. Xegacres()    /* change screen resolution */
  452. X
  453. X{
  454. X    return(TRUE);
  455. X}
  456. X
  457. Xegabeep()
  458. X{
  459. X    bdos(6, BEL, 0);
  460. X}
  461. X
  462. Xegaopen()
  463. X{
  464. X    char buf;    /* buffer for peek/poke */
  465. X
  466. X    /* initialize pointers to the screen ram */
  467. X    scinit();
  468. X
  469. X    /* and put the beast into EGA 43 row mode */
  470. X    rg.x.ax = 3;
  471. X    int86(0x10, &rg, &rg);
  472. X
  473. X    rg.x.ax = 0x1112;
  474. X    rg.h.bl = 0;
  475. X    int86(0x10, &rg, &rg);
  476. X
  477. X    peek(0x40, 0x87, &buf, 1);
  478. X    buf |= 1;
  479. X    poke(0x40, 0x87, &buf, 1);
  480. X    buf = 0xf8;
  481. X    poke(0x40, 0x88, &buf, 1);
  482. X
  483. X    rg.x.ax = 0x0100;
  484. X    rg.h.bh = 0;
  485. X    rg.x.cx = 0x0007;
  486. X    int86(0x10, &rg, &rg);
  487. X
  488. X    buf = 0xf9;
  489. X    poke(0x40, 0x88, &buf, 1);
  490. X
  491. X    strcpy(sres, "43LINE");
  492. X    revexist = TRUE;
  493. X        ttopen();
  494. X}
  495. X
  496. Xegaclose()
  497. X
  498. X{
  499. X    char buf;    /* buffer for peek/poke */
  500. X
  501. X#if    COLOR
  502. X    egafcol(7);
  503. X    egabcol(0);
  504. X#endif
  505. X    /* and put the beast into 80 column mode */
  506. X    rg.x.ax = 0002;
  507. X    int86(0x10, &rg, &rg);
  508. X    ttclose();
  509. X
  510. X#if    0
  511. X    peek(0x40, 0x87, &buf, 1);
  512. X    buf--;
  513. X    poke(0x40, 0x87, &buf, 1);
  514. X#endif
  515. X
  516. X    /* and restore the normal cursor */
  517. X    rg.x.ax = 0x0100;
  518. X    rg.h.bl = 0;
  519. X    rg.x.cx = 0x0b0d;
  520. X    int86(0x10, &rg, &rg);
  521. X}
  522. X
  523. Xegakopen()
  524. X
  525. X{
  526. X}
  527. X
  528. Xegakclose()
  529. X
  530. X{
  531. X}
  532. X
  533. Xscinit()    /* initialize the screen head pointers */
  534. X
  535. X{
  536. X    union {
  537. X        long laddr;    /* long form of address */
  538. X        int *paddr;    /* pointer form of address */
  539. X    } addr;
  540. X    int i;
  541. X
  542. X    /* initialize the screen pointer array */
  543. X    for (i = 0; i < NROW; i++) {
  544. X        addr.laddr = SCADD + (long)(NCOL * i * 2);
  545. X        scptr[i] = addr.paddr;
  546. X    }
  547. X}
  548. X
  549. Xscwrite(row, outstr, forg, bacg)    /* write a line out*/
  550. X
  551. Xint row;    /* row of screen to place outstr on */
  552. Xchar *outstr;    /* string to write out (must be NCOL long) */
  553. Xint forg;    /* forground color of string to write */
  554. Xint bacg;    /* background color */
  555. X
  556. X{
  557. X    int attr;    /* attribute byte mask to place in RAM */
  558. X    int *lnptr;    /* pointer to the destination line */
  559. X    int i;
  560. X
  561. X    /* build the attribute byte and setup the screen pointer */
  562. X#if    COLOR
  563. X    attr = (((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) << 8;
  564. X#else
  565. X    attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
  566. X#endif
  567. X    lnptr = &sline[0];
  568. X    for (i=0; i<term.t_ncol; i++)
  569. X        *lnptr++ = (outstr[i] & 255) | attr;
  570. X
  571. X    if (flickcode) {
  572. X        /* wait for vertical retrace to be off */
  573. X        while ((inp(0x3da) & 8))
  574. X            ;
  575. X
  576. X        /* and to be back on */
  577. X        while ((inp(0x3da) & 8) == 0)
  578. X            ;
  579. X    }
  580. X
  581. X    /* and send the string out */
  582. X    movmem(&sline[0], scptr[row],term.t_ncol*2);
  583. X}
  584. X
  585. X#if    FLABEL
  586. Xfnclabel(f, n)        /* label a function key */
  587. X
  588. Xint f,n;    /* default flag, numeric argument [unused] */
  589. X
  590. X{
  591. X    /* on machines with no function keys...don't bother */
  592. X    return(TRUE);
  593. X}
  594. X#endif
  595. X#else
  596. Xegahello()
  597. X{
  598. X}
  599. X#endif
  600. END_OF_egapc.c
  601. if test 6871 -ne `wc -c <egapc.c`; then
  602.     echo shar: \"egapc.c\" unpacked with wrong size!
  603. fi
  604. # end of overwriting check
  605. fi
  606. echo shar: Extracting \"emacs.key\" \(5313 characters\)
  607. if test -f emacs.key ; then 
  608.   echo shar: Will not over-write existing file \"emacs.key\"
  609. else
  610. sed "s/^X//" >emacs.key <<'END_OF_emacs.key'
  611. X        Default Key Bindings for MicroEmacs 3.8b    (01/22/87)
  612. X        ========================================
  613. X
  614. X ^A   Move to start of line           ESC A   Apropos (list some commands)
  615. X ^B   Move backward by characters     ESC B   Backup by words
  616. X ^C   Insert space                    ESC C   Initial capitalize word
  617. X ^D   Forward delete                  ESC D   Delete forward word
  618. X ^E   Goto end of line                ESC E   Reset Encryption Key
  619. X ^F   Move forward by characters      ESC F   Advance by words
  620. X ^G   Abort out of things             ESC G   Go to a line
  621. X ^H   Backward delete                 
  622. X ^I   Insert tab/Set tab stops
  623. X ^J   Insert CR-LF, then indent                     
  624. X ^K   Kill forward                    ESC K   Bind Key to function
  625. X ^L   Refresh the screen              ESC L   Lower case word
  626. X ^M   Insert CR-LF                    ESC M   Add global mode
  627. X ^N   Move forward by lines           ESC N   Goto End paragraph
  628. X ^O   Open up a blank line            
  629. X ^P   Move backward by lines          ESC P   Goto Begining of paragraph
  630. X ^Q   Insert literal                  ESC Q   Fill current paragraph
  631. X ^R   Search backwards                ESC R   Search and replace
  632. X ^S   Search forward                  ESC S   Suspend MicroEMACS (BSD4.2 only)
  633. X ^T   Transpose characters
  634. X ^U   Repeat command four times       ESC U   Upper case word
  635. X ^V   Move forward by pages           ESC V   Move backward by pages
  636. X ^W   Kill region                     ESC W   Copy region to kill buffer
  637. X ^Y   Yank back from killbuffer       ESC X   Execute named command
  638. X ^Z   Move backward by pages          ESC Z   Save all buffers and exit
  639. X
  640. X ESC ^C   Count words in region       ESC ~   Unmark current buffer
  641. X ESC ^F   Goto matching fence         ESC !   Reposition window
  642. X ESC ^H   Delete backward word        ESC <   Move to start of buffer
  643. X ESC ^K   Unbind Key from function    ESC >   Move to end of buffer
  644. X ESC ^L   Reposition window           ESC .   Set mark
  645. X ESC ^M   Delete global mode          ESC ?   Fetch HELP file to buffer
  646. X ESC ^N   Rename current buffer       ESC space    Set mark
  647. X ESC ^R   Search & replace w/query    ESC rubout   Delete backward word
  648. X ESC ^S   Change screen rows              rubout   Backward delete
  649. X ESC ^T   Change screen columns
  650. X ESC ^V   Scroll next window down
  651. X ESC ^W   Delete Paragraph
  652. X ESC ^Z   Scroll next window up
  653. X
  654. X ^X ?   Describe a key             ^X !   Run 1 command in a subjob
  655. X ^X =   Show the cursor position   ^X @   Pipe DOS command to buffer
  656. X ^X ^   Enlarge display window     ^X #   Filter buffer thru DOS filter
  657. X ^X 0   Delete current window      ^X (   Begin macro
  658. X ^X 1   Delete other windows       ^X )   End macro
  659. X ^X 2   Split current window
  660. X                                   ^X A   Set variable value
  661. X ^X ^B   Display buffer list       ^X B   Switch a window to a buffer
  662. X ^X ^C   Exit MicroEMACS           ^X C   Start a new command processer
  663. X                                   ^X D   Suspend MicroEMACS (BSD4.2 only)
  664. X                                   ^X E   Execute macro
  665. X ^X ^F   Find file                 ^X F   Set fill column
  666. X ^X ^I   Insert file
  667. X                                   ^X K   Delete buffer
  668. X ^X ^L   Lower case region
  669. X ^X ^M   Delete Mode               ^X M   Add a mode
  670. X ^X ^N   Move window down          ^X N   Rename current filename
  671. X ^X ^O   Delete blank lines        ^X O   Move to the next window
  672. X ^X ^P   Move window up            ^X P   Move to the previous window
  673. X ^X ^R   Get a file from disk      ^X R   Incremental reverse search
  674. X ^X ^S   Save current file         ^X S   Incremental forward search
  675. X ^X ^U   Upper case region
  676. X ^X ^V   View file
  677. X ^X ^W   Write a file to disk      ^X W   resize Window
  678. X ^X ^X   Swap "." and mark         ^X X   Use next buffer
  679. X ^X ^Z   Shrink window             ^X Z   Enlarge display window
  680. X
  681. XOnly under PCDOS:
  682. X <ALT>-S Hunt forward        SHIFT <F1> - <F10>
  683. X <ALT>-R Hunt backward           Execute macroes 1 - 10
  684. X
  685. XSome unbound commands:
  686. X======================
  687. Xexecute-buffer        execute a buffer od command lines
  688. Xexecute-command-line    execute a command line (n <command> <args>)
  689. Xexecute-file        execute a file of command lines
  690. Xexecute-named-command    execute a command by name (w/command completion)
  691. Xexecute-macro-[1-40]    execute macroes 1 thru 40
  692. Xdescribe-bindings    pull the list of current bindings into a window
  693. Xhunt-forward        find next occurance of search string
  694. Xhunt-backward        find last occurance of search string
  695. X
  696. XUsable Modes
  697. X============
  698. XWRAP     Lines going past right margin "wrap" to a new line
  699. XVIEW     Read-Only mode where no modifications are allowed
  700. XCMODE    Change behavior of some commands to work with C better
  701. XEXACT    Exact case matching on search strings
  702. XOVER     Overwrite typed characters instead of inserting them
  703. XCRYPT    Current buffer will be encrypted on write, decrypted on read
  704. XMAGIC    Use regular expresion matching in searches
  705. X
  706. XWHITE/CYAN/MAGENTA/YELLOW/BLUE/RED/GREEN/BLACK    Sets foreground color
  707. Xwhite/cyan/magenta/yellow/blue/red/green/black    Sets background color
  708. X
  709. XMAGIC MODE special characters
  710. X=============================
  711. X^    Anchor search at beginning of line
  712. X$    Anchor search at end of line
  713. X.    Match any character except <NL>
  714. X*    Match zero or more of the preceeding character
  715. X[]    Match a class of characters ([a-z] would be all alphabetics)
  716. X\    Take next literally
  717. X
  718. END_OF_emacs.key
  719. if test 5313 -ne `wc -c <emacs.key`; then
  720.     echo shar: \"emacs.key\" unpacked with wrong size!
  721. fi
  722. # end of overwriting check
  723. fi
  724. echo shar: Extracting \"ibmpc.c\" \(7249 characters\)
  725. if test -f ibmpc.c ; then 
  726.   echo shar: Will not over-write existing file \"ibmpc.c\"
  727. else
  728. sed "s/^X//" >ibmpc.c <<'END_OF_ibmpc.c'
  729. X/*
  730. X * The routines in this file provide support for the IBM-PC and other
  731. X * compatible terminals. It goes directly to the graphics RAM to do
  732. X * screen output. It compiles into nothing if not an IBM-PC driver
  733. X */
  734. X
  735. X#define    termdef    1            /* don't define "term" external */
  736. X
  737. X#include        <stdio.h>
  738. X#include    "estruct.h"
  739. X#include        "edef.h"
  740. X
  741. X#if     IBMPC
  742. X
  743. X#define NROW    25                      /* Screen size.                 */
  744. X#define NCOL    80                      /* Edit if you want to.         */
  745. X#define    MARGIN    8            /* size of minimim margin and    */
  746. X#define    SCRSIZ    64            /* scroll size for extended lines */
  747. X#define    NPAUSE    200            /* # times thru update to pause */
  748. X#define BEL     0x07                    /* BEL character.               */
  749. X#define ESC     0x1B                    /* ESC character.               */
  750. X#define    SPACE    32            /* space character        */
  751. X
  752. X#define    SCADC    0xb8000000L        /* CGA address of screen RAM    */
  753. X#define    SCADM    0xb0000000L        /* MONO address of screen RAM    */
  754. X
  755. X#define    CDCGA    0            /* color graphics card        */
  756. X#define    CDMONO    1            /* monochrome text card        */
  757. X#define    CDSENSE    9            /* detect the card type        */
  758. X
  759. Xint dtype = CDCGA;            /* current display type        */
  760. Xlong scadd;                /* address of screen ram    */
  761. Xint *scptr[NROW];            /* pointer to screen lines    */
  762. Xint sline[NCOL];            /* screen line image        */
  763. Xextern union REGS rg;            /* cpu register for use of DOS calls */
  764. X
  765. Xextern  int     ttopen();               /* Forward references.          */
  766. Xextern  int     ttgetc();
  767. Xextern  int     ttputc();
  768. Xextern  int     ttflush();
  769. Xextern  int     ttclose();
  770. Xextern  int     ibmmove();
  771. Xextern  int     ibmeeol();
  772. Xextern  int     ibmeeop();
  773. Xextern  int     ibmbeep();
  774. Xextern  int     ibmopen();
  775. Xextern    int    ibmrev();
  776. Xextern    int    ibmcres();
  777. Xextern    int    ibmclose();
  778. Xextern    int    ibmputc();
  779. Xextern    int    ibmkopen();
  780. Xextern    int    ibmkclose();
  781. X
  782. X#if    COLOR
  783. Xextern    int    ibmfcol();
  784. Xextern    int    ibmbcol();
  785. X
  786. Xint    cfcolor = -1;        /* current forground color */
  787. Xint    cbcolor = -1;        /* current background color */
  788. Xint    ctrans[] =        /* ansi to ibm color translation table */
  789. X    {0, 4, 2, 6, 1, 5, 3, 7};
  790. X#endif
  791. X
  792. X/*
  793. X * Standard terminal interface dispatch table. Most of the fields point into
  794. X * "termio" code.
  795. X */
  796. XTERM    term    = {
  797. X    NROW-1,
  798. X        NROW-1,
  799. X        NCOL,
  800. X        NCOL,
  801. X    MARGIN,
  802. X    SCRSIZ,
  803. X    NPAUSE,
  804. X        ibmopen,
  805. X        ibmclose,
  806. X    ibmkopen,
  807. X    ibmkclose,
  808. X        ttgetc,
  809. X    ibmputc,
  810. X        ttflush,
  811. X        ibmmove,
  812. X        ibmeeol,
  813. X        ibmeeop,
  814. X        ibmbeep,
  815. X    ibmrev,
  816. X    ibmcres
  817. X#if    COLOR
  818. X    , ibmfcol,
  819. X    ibmbcol
  820. X#endif
  821. X};
  822. X
  823. Xextern union REGS rg;
  824. X
  825. X#if    COLOR
  826. Xibmfcol(color)        /* set the current output color */
  827. X
  828. Xint color;    /* color to set */
  829. X
  830. X{
  831. X    cfcolor = ctrans[color];
  832. X}
  833. X
  834. Xibmbcol(color)        /* set the current background color */
  835. X
  836. Xint color;    /* color to set */
  837. X
  838. X{
  839. X        cbcolor = ctrans[color];
  840. X}
  841. X#endif
  842. X
  843. Xibmmove(row, col)
  844. X{
  845. X    rg.h.ah = 2;        /* set cursor position function code */
  846. X    rg.h.dl = col;
  847. X    rg.h.dh = row;
  848. X    rg.h.bh = 0;        /* set screen page number */
  849. X    int86(0x10, &rg, &rg);
  850. X}
  851. X
  852. Xibmeeol()    /* erase to the end of the line */
  853. X
  854. X{
  855. X    int attr;    /* attribute byte mask to place in RAM */
  856. X    int *lnptr;    /* pointer to the destination line */
  857. X    int i;
  858. X    int ccol;    /* current column cursor lives */
  859. X    int crow;    /*       row    */
  860. X
  861. X    /* find the current cursor position */
  862. X    rg.h.ah = 3;        /* read cursor position function code */
  863. X    rg.h.bh = 0;        /* current video page */
  864. X    int86(0x10, &rg, &rg);
  865. X    ccol = rg.h.dl;        /* record current column */
  866. X    crow = rg.h.dh;        /* and row */
  867. X
  868. X    /* build the attribute byte and setup the screen pointer */
  869. X#if    COLOR
  870. X    if (dtype == CDCGA)
  871. X        attr = (((cbcolor & 15) << 4) | (cfcolor & 15)) << 8;
  872. X    else
  873. X        attr = 0x0700;
  874. X#else
  875. X    attr = 0x0700;
  876. X#endif
  877. X    lnptr = &sline[0];
  878. X    for (i=0; i < term.t_ncol; i++)
  879. X        *lnptr++ = SPACE | attr;
  880. X
  881. X    if (flickcode) {
  882. X        /* wait for vertical retrace to be off */
  883. X        while ((inp(0x3da) & 8))
  884. X            ;
  885. X    
  886. X        /* and to be back on */
  887. X        while ((inp(0x3da) & 8) == 0)
  888. X            ;
  889. X    }            
  890. X
  891. X    /* and send the string out */
  892. X    movmem(&sline[0], scptr[crow]+ccol, (term.t_ncol-ccol)*2);
  893. X
  894. X}
  895. X
  896. Xibmputc(ch)    /* put a character at the current position in the
  897. X           current colors */
  898. X
  899. Xint ch;
  900. X
  901. X{
  902. X    rg.h.ah = 14;        /* write char to screen with current attrs */
  903. X    rg.h.al = ch;
  904. X#if    COLOR
  905. X    if (dtype == CDCGA)
  906. X        rg.h.bl = cfcolor;
  907. X    else
  908. X        rg.h.bl = 0x07;
  909. X#else
  910. X    rg.h.bl = 0x07;
  911. X#endif
  912. X    int86(0x10, &rg, &rg);
  913. X}
  914. X
  915. Xibmeeop()
  916. X{
  917. X    int attr;        /* attribute to fill screen with */
  918. X
  919. X    rg.h.ah = 6;        /* scroll page up function code */
  920. X    rg.h.al = 0;        /* # lines to scroll (clear it) */
  921. X    rg.x.cx = 0;        /* upper left corner of scroll */
  922. X    rg.x.dx = 0x184f;    /* lower right corner of scroll */
  923. X#if    COLOR
  924. X    if (dtype == CDCGA)
  925. X        attr = ((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15);
  926. X    else
  927. X        attr = 0;
  928. X#else
  929. X    attr = 0;
  930. X#endif
  931. X    rg.h.bh = attr;
  932. X    int86(0x10, &rg, &rg);
  933. X}
  934. X
  935. Xibmrev(state)        /* change reverse video state */
  936. X
  937. Xint state;    /* TRUE = reverse, FALSE = normal */
  938. X
  939. X{
  940. X    /* This never gets used under the IBM-PC driver */
  941. X}
  942. X
  943. Xibmcres(res)    /* change screen resolution */
  944. X
  945. Xchar *res;    /* resolution to change to */
  946. X
  947. X{
  948. X    if (strcmp(res, "CGA") == 0) {
  949. X        scinit(CDCGA);
  950. X        return(TRUE);
  951. X    } else if (strcmp(res, "MONO") == 0) {
  952. X        scinit(CDMONO);
  953. X        return(TRUE);
  954. X    } else
  955. X        return(FALSE);
  956. X}
  957. X
  958. Xibmbeep()
  959. X{
  960. X#if    MWC86
  961. X    putcnb(BEL);
  962. X#else
  963. X    bdos(6, BEL, 0);
  964. X#endif
  965. X}
  966. X
  967. Xibmopen()
  968. X{
  969. X    scinit(CDSENSE);
  970. X    revexist = TRUE;
  971. X        ttopen();
  972. X}
  973. X
  974. Xibmclose()
  975. X
  976. X{
  977. X#if    COLOR
  978. X    ibmfcol(7);
  979. X    ibmbcol(0);
  980. X#endif
  981. X    ttclose();
  982. X}
  983. X
  984. Xibmkopen()    /* open the keyboard */
  985. X
  986. X{
  987. X}
  988. X
  989. Xibmkclose()    /* close the keyboard */
  990. X
  991. X{
  992. X}
  993. X
  994. Xscinit(type)    /* initialize the screen head pointers */
  995. X
  996. Xint type;    /* type of adapter to init for */
  997. X
  998. X{
  999. X    union {
  1000. X        long laddr;    /* long form of address */
  1001. X        int *paddr;    /* pointer form of address */
  1002. X    } addr;
  1003. X    int i;
  1004. X
  1005. X    /* if asked...find out what display is connected */
  1006. X    int86(0x11, &rg, &rg);
  1007. X    dtype = CDCGA;
  1008. X    scadd = SCADC;
  1009. X    strcpy(sres, "CGA");
  1010. X    if ((((rg.x.ax >> 4) & 11) == 3) || type == CDMONO) {
  1011. X        strcpy(sres, "MONO");
  1012. X        dtype = CDMONO;
  1013. X        scadd = SCADM;
  1014. X    }
  1015. X
  1016. X    /* initialize the screen pointer array */
  1017. X    for (i = 0; i < NROW; i++) {
  1018. X        addr.laddr = scadd + (long)(NCOL * i * 2);
  1019. X        scptr[i] = addr.paddr;
  1020. X    }
  1021. X}
  1022. X
  1023. Xscwrite(row, outstr, forg, bacg)    /* write a line out*/
  1024. X
  1025. Xint row;    /* row of screen to place outstr on */
  1026. Xchar *outstr;    /* string to write out (must be term.t_ncol long) */
  1027. Xint forg;    /* forground color of string to write */
  1028. Xint bacg;    /* background color */
  1029. X
  1030. X{
  1031. X    int attr;    /* attribute byte mask to place in RAM */
  1032. X    int *lnptr;    /* pointer to the destination line */
  1033. X    int i;
  1034. X
  1035. X    /* build the attribute byte and setup the screen pointer */
  1036. X#if    COLOR
  1037. X    if (dtype == CDCGA)
  1038. X        attr = (((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) << 8;
  1039. X    else
  1040. X        attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
  1041. X#else
  1042. X    attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
  1043. X#endif
  1044. X    lnptr = &sline[0];
  1045. X    for (i=0; i<term.t_ncol; i++)
  1046. X        *lnptr++ = (outstr[i] & 255) | attr;
  1047. X
  1048. X    if (flickcode) {
  1049. X        /* wait for vertical retrace to be off */
  1050. X        while ((inp(0x3da) & 8))
  1051. X            ;
  1052. X    
  1053. X        /* and to be back on */
  1054. X        while ((inp(0x3da) & 8) == 0)
  1055. X            ;
  1056. X    }
  1057. X
  1058. X    /* and send the string out */
  1059. X    movmem(&sline[0], scptr[row],term.t_ncol*2);
  1060. X}
  1061. X
  1062. X#if    FLABEL
  1063. Xfnclabel(f, n)        /* label a function key */
  1064. X
  1065. Xint f,n;    /* default flag, numeric argument [unused] */
  1066. X
  1067. X{
  1068. X    /* on machines with no function keys...don't bother */
  1069. X    return(TRUE);
  1070. X}
  1071. X#endif
  1072. X#else
  1073. Xibmhello()
  1074. X{
  1075. X}
  1076. X#endif
  1077. END_OF_ibmpc.c
  1078. if test 7249 -ne `wc -c <ibmpc.c`; then
  1079.     echo shar: \"ibmpc.c\" unpacked with wrong size!
  1080. fi
  1081. # end of overwriting check
  1082. fi
  1083. echo shar: Extracting \"region.c\" \(7029 characters\)
  1084. if test -f region.c ; then 
  1085.   echo shar: Will not over-write existing file \"region.c\"
  1086. else
  1087. sed "s/^X//" >region.c <<'END_OF_region.c'
  1088. X/*
  1089. X * The routines in this file
  1090. X * deal with the region, that magic space
  1091. X * between "." and mark. Some functions are
  1092. X * commands. Some functions are just for
  1093. X * internal use.
  1094. X */
  1095. X#include        <stdio.h>
  1096. X#include    "estruct.h"
  1097. X#include        "edef.h"
  1098. X
  1099. X#if    MEGAMAX & ST520
  1100. Xoverlay    "region"
  1101. X#endif
  1102. X
  1103. X/*
  1104. X * Kill the region. Ask "getregion"
  1105. X * to figure out the bounds of the region.
  1106. X * Move "." to the start, and kill the characters.
  1107. X * Bound to "C-W".
  1108. X */
  1109. Xkillregion(f, n)
  1110. X{
  1111. X        register int    s;
  1112. X        REGION          region;
  1113. X
  1114. X    if (curbp->b_mode&MDVIEW)    /* don't allow this command if    */
  1115. X        return(rdonly());    /* we are in read only mode    */
  1116. X        if ((s=getregion(®ion)) != TRUE)
  1117. X                return (s);
  1118. X        if ((lastflag&CFKILL) == 0)             /* This is a kill type  */
  1119. X                kdelete();                      /* command, so do magic */
  1120. X        thisflag |= CFKILL;                     /* kill buffer stuff.   */
  1121. X        curwp->w_dotp = region.r_linep;
  1122. X        curwp->w_doto = region.r_offset;
  1123. X        return (ldelete(region.r_size, TRUE));
  1124. X}
  1125. X
  1126. X/*
  1127. X * Copy all of the characters in the
  1128. X * region to the kill buffer. Don't move dot
  1129. X * at all. This is a bit like a kill region followed
  1130. X * by a yank. Bound to "M-W".
  1131. X */
  1132. Xcopyregion(f, n)
  1133. X{
  1134. X        register LINE   *linep;
  1135. X        register int    loffs;
  1136. X        register int    s;
  1137. X        REGION          region;
  1138. X
  1139. X        if ((s=getregion(®ion)) != TRUE)
  1140. X                return (s);
  1141. X        if ((lastflag&CFKILL) == 0)             /* Kill type command.   */
  1142. X                kdelete();
  1143. X        thisflag |= CFKILL;
  1144. X        linep = region.r_linep;                 /* Current line.        */
  1145. X        loffs = region.r_offset;                /* Current offset.      */
  1146. X        while (region.r_size--) {
  1147. X                if (loffs == llength(linep)) {  /* End of line.         */
  1148. X                        if ((s=kinsert('\n')) != TRUE)
  1149. X                                return (s);
  1150. X                        linep = lforw(linep);
  1151. X                        loffs = 0;
  1152. X                } else {                        /* Middle of line.      */
  1153. X                        if ((s=kinsert(lgetc(linep, loffs))) != TRUE)
  1154. X                                return (s);
  1155. X                        ++loffs;
  1156. X                }
  1157. X        }
  1158. X        return (TRUE);
  1159. X}
  1160. X
  1161. X/*
  1162. X * Lower case region. Zap all of the upper
  1163. X * case characters in the region to lower case. Use
  1164. X * the region code to set the limits. Scan the buffer,
  1165. X * doing the changes. Call "lchange" to ensure that
  1166. X * redisplay is done in all buffers. Bound to
  1167. X * "C-X C-L".
  1168. X */
  1169. Xlowerregion(f, n)
  1170. X{
  1171. X        register LINE   *linep;
  1172. X        register int    loffs;
  1173. X        register int    c;
  1174. X        register int    s;
  1175. X        REGION          region;
  1176. X
  1177. X    if (curbp->b_mode&MDVIEW)    /* don't allow this command if    */
  1178. X        return(rdonly());    /* we are in read only mode    */
  1179. X        if ((s=getregion(®ion)) != TRUE)
  1180. X                return (s);
  1181. X        lchange(WFHARD);
  1182. X        linep = region.r_linep;
  1183. X        loffs = region.r_offset;
  1184. X        while (region.r_size--) {
  1185. X                if (loffs == llength(linep)) {
  1186. X                        linep = lforw(linep);
  1187. X                        loffs = 0;
  1188. X                } else {
  1189. X                        c = lgetc(linep, loffs);
  1190. X                        if (c>='A' && c<='Z')
  1191. X                                lputc(linep, loffs, c+'a'-'A');
  1192. X                        ++loffs;
  1193. X                }
  1194. X        }
  1195. X        return (TRUE);
  1196. X}
  1197. X
  1198. X/*
  1199. X * Upper case region. Zap all of the lower
  1200. X * case characters in the region to upper case. Use
  1201. X * the region code to set the limits. Scan the buffer,
  1202. X * doing the changes. Call "lchange" to ensure that
  1203. X * redisplay is done in all buffers. Bound to
  1204. X * "C-X C-L".
  1205. X */
  1206. Xupperregion(f, n)
  1207. X{
  1208. X        register LINE   *linep;
  1209. X        register int    loffs;
  1210. X        register int    c;
  1211. X        register int    s;
  1212. X        REGION          region;
  1213. X
  1214. X    if (curbp->b_mode&MDVIEW)    /* don't allow this command if    */
  1215. X        return(rdonly());    /* we are in read only mode    */
  1216. X        if ((s=getregion(®ion)) != TRUE)
  1217. X                return (s);
  1218. X        lchange(WFHARD);
  1219. X        linep = region.r_linep;
  1220. X        loffs = region.r_offset;
  1221. X        while (region.r_size--) {
  1222. X                if (loffs == llength(linep)) {
  1223. X                        linep = lforw(linep);
  1224. X                        loffs = 0;
  1225. X                } else {
  1226. X                        c = lgetc(linep, loffs);
  1227. X                        if (c>='a' && c<='z')
  1228. X                                lputc(linep, loffs, c-'a'+'A');
  1229. X                        ++loffs;
  1230. X                }
  1231. X        }
  1232. X        return (TRUE);
  1233. X}
  1234. X
  1235. X/*
  1236. X * This routine figures out the
  1237. X * bounds of the region in the current window, and
  1238. X * fills in the fields of the "REGION" structure pointed
  1239. X * to by "rp". Because the dot and mark are usually very
  1240. X * close together, we scan outward from dot looking for
  1241. X * mark. This should save time. Return a standard code.
  1242. X * Callers of this routine should be prepared to get
  1243. X * an "ABORT" status; we might make this have the
  1244. X * conform thing later.
  1245. X */
  1246. Xgetregion(rp)
  1247. Xregister REGION *rp;
  1248. X{
  1249. X        register LINE   *flp;
  1250. X        register LINE   *blp;
  1251. X        long fsize;
  1252. X        long bsize;
  1253. X
  1254. X        if (curwp->w_markp == NULL) {
  1255. X                mlwrite("No mark set in this window");
  1256. X                return (FALSE);
  1257. X        }
  1258. X        if (curwp->w_dotp == curwp->w_markp) {
  1259. X                rp->r_linep = curwp->w_dotp;
  1260. X                if (curwp->w_doto < curwp->w_marko) {
  1261. X                        rp->r_offset = curwp->w_doto;
  1262. X                        rp->r_size = (long)(curwp->w_marko-curwp->w_doto);
  1263. X                } else {
  1264. X                        rp->r_offset = curwp->w_marko;
  1265. X                        rp->r_size = (long)(curwp->w_doto-curwp->w_marko);
  1266. X                }
  1267. X                return (TRUE);
  1268. X        }
  1269. X        blp = curwp->w_dotp;
  1270. X        bsize = (long)curwp->w_doto;
  1271. X        flp = curwp->w_dotp;
  1272. X        fsize = (long)(llength(flp)-curwp->w_doto+1);
  1273. X        while (flp!=curbp->b_linep || lback(blp)!=curbp->b_linep) {
  1274. X                if (flp != curbp->b_linep) {
  1275. X                        flp = lforw(flp);
  1276. X                        if (flp == curwp->w_markp) {
  1277. X                                rp->r_linep = curwp->w_dotp;
  1278. X                                rp->r_offset = curwp->w_doto;
  1279. X                                rp->r_size = fsize+curwp->w_marko;
  1280. X                                return (TRUE);
  1281. X                        }
  1282. X                        fsize += llength(flp)+1;
  1283. X                }
  1284. X                if (lback(blp) != curbp->b_linep) {
  1285. X                        blp = lback(blp);
  1286. X                        bsize += llength(blp)+1;
  1287. X                        if (blp == curwp->w_markp) {
  1288. X                                rp->r_linep = blp;
  1289. X                                rp->r_offset = curwp->w_marko;
  1290. X                                rp->r_size = bsize - curwp->w_marko;
  1291. X                                return (TRUE);
  1292. X                        }
  1293. X                }
  1294. X        }
  1295. X        mlwrite("Bug: lost mark");
  1296. X        return (FALSE);
  1297. X}
  1298. END_OF_region.c
  1299. if test 7029 -ne `wc -c <region.c`; then
  1300.     echo shar: \"region.c\" unpacked with wrong size!
  1301. fi
  1302. # end of overwriting check
  1303. fi
  1304. echo shar: Extracting \"tipc.c\" \(5241 characters\)
  1305. if test -f tipc.c ; then 
  1306.   echo shar: Will not over-write existing file \"tipc.c\"
  1307. else
  1308. sed "s/^X//" >tipc.c <<'END_OF_tipc.c'
  1309. X/*
  1310. X * The routines in this file provide support for the TI-PC and other
  1311. X * compatible terminals. It goes directly to the graphics RAM to do
  1312. X * screen output. It compiles into nothing if not a TI-PC driver
  1313. X */
  1314. X
  1315. X#define termdef 1                       /* don't define "term" external */
  1316. X
  1317. X#include        <stdio.h>
  1318. X#include        "estruct.h"
  1319. X#include        "edef.h"
  1320. X
  1321. X#if     TIPC
  1322. X
  1323. X#define NROW    25                      /* Screen size.                 */
  1324. X#define NCOL    80                      /* Edit if you want to.         */
  1325. X#define MARGIN  8                       /* size of minimim margin and   */
  1326. X#define SCRSIZ  64                      /* scroll size for extended lines */
  1327. X#define NPAUSE  200                     /* # times thru update to pause */
  1328. X#define BEL     0x07                    /* BEL character.               */
  1329. X#define ESC     0x1B                    /* ESC character.               */
  1330. X#define SPACE   32                      /* space character              */
  1331. X#define SCADD   0xDE000L                /* address of screen RAM        */
  1332. X
  1333. X#define CHAR_ENABLE     0x08            /* TI attribute to show char    */
  1334. X#define TI_REVERSE      0x10            /* TI attribute to reverse char */
  1335. X#define BLACK   0+CHAR_ENABLE           /* TI attribute for Black       */
  1336. X#define BLUE    1+CHAR_ENABLE           /* TI attribute for Blue        */
  1337. X#define RED     2+CHAR_ENABLE           /* TI attribute for Red         */
  1338. X#define MAGENTA 3+CHAR_ENABLE           /* TI attribute for Magenta     */
  1339. X#define GREEN   4+CHAR_ENABLE           /* TI attribute for Green       */
  1340. X#define CYAN    5+CHAR_ENABLE           /* TI attribute for Cyan        */
  1341. X#define YELLOW  6+CHAR_ENABLE           /* TI attribute for Yellow      */
  1342. X#define WHITE   7+CHAR_ENABLE           /* TI attribute for White       */
  1343. X
  1344. X
  1345. Xextern  int     ttopen();               /* Forward references.          */
  1346. Xextern  int     ttgetc();
  1347. Xextern  int     ttputc();
  1348. Xextern  int     ttflush();
  1349. Xextern  int     ttclose();
  1350. Xextern  int     timove();
  1351. Xextern  int     tieeol();
  1352. Xextern  int     tieeop();
  1353. Xextern  int     tibeep();
  1354. Xextern  int     tiopen();
  1355. Xextern  int     tirev();
  1356. Xextern    int    ticres();
  1357. Xextern  int     ticlose();
  1358. Xextern  int     tiputc();
  1359. X
  1360. X#if     COLOR
  1361. Xextern  int     tifcol();
  1362. Xextern  int     tibcol();
  1363. X
  1364. Xint     cfcolor = -1;           /* current forground color */
  1365. Xint     cbcolor = -1;           /* current background color */
  1366. Xint     ctrans[] =              /* ansi to ti color translation table */
  1367. X        {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
  1368. X#endif
  1369. X
  1370. X/*
  1371. X * Standard terminal interface dispatch table. Most of the fields point into
  1372. X * "termio" code.
  1373. X */
  1374. XTERM    term    = {
  1375. X    NROW-1,
  1376. X        NROW-1,
  1377. X        NCOL,
  1378. X        NCOL,
  1379. X        MARGIN,
  1380. X        SCRSIZ,
  1381. X        NPAUSE,
  1382. X        tiopen,
  1383. X        ticlose,
  1384. X        ttgetc,
  1385. X        tiputc,
  1386. X        ttflush,
  1387. X        timove,
  1388. X        tieeol,
  1389. X        tieeop,
  1390. X        tibeep,
  1391. X        tirev,
  1392. X        ticres
  1393. X#if     COLOR
  1394. X        , tifcol,
  1395. X        tibcol
  1396. X#endif
  1397. X};
  1398. X
  1399. Xextern union REGS rg;
  1400. X
  1401. X#if     COLOR
  1402. Xsetatt( attr )
  1403. Xint attr;
  1404. X{
  1405. X        rg.h.ah = 0x16;         /* set the forground character attribute */
  1406. X        rg.h.bl = attr;
  1407. X        int86( 0x49, &rg, &rg );
  1408. X}
  1409. X
  1410. Xtifcol(color)           /* set the current output color */
  1411. X
  1412. Xint color;      /* color to set */
  1413. X
  1414. X{
  1415. X        cfcolor = ctrans[color];
  1416. X        setatt ( cfcolor );
  1417. X}
  1418. X
  1419. Xtibcol(color)           /* set the current background color */
  1420. X
  1421. Xint color;      /* color to set */
  1422. X
  1423. X{
  1424. X        cbcolor = ctrans[color];
  1425. X}
  1426. X#endif
  1427. X
  1428. Xtimove(row, col)
  1429. X{
  1430. X        rg.h.ah = 2;            /* set cursor position function code */
  1431. X        rg.h.dh = col;
  1432. X        rg.h.dl = row;
  1433. X        int86(0x49, &rg, &rg);
  1434. X}
  1435. X
  1436. Xtieeol()        /* erase to the end of the line */
  1437. X
  1438. X{
  1439. X        int ccol;       /* current column cursor lives */
  1440. X        int crow;       /*         row  */
  1441. X
  1442. X        /* find the current cursor position */
  1443. X        rg.h.ah = 3;            /* read cursor position function code */
  1444. X        int86(0x49, &rg, &rg);
  1445. X        ccol = rg.h.dh;         /* record current column */
  1446. X        crow = rg.h.dl;         /* and row */
  1447. X
  1448. X        rg.h.ah = 0x09;         /* Write character at cursor position */
  1449. X        rg.h.al = ' ';          /* Space */
  1450. X        rg.h.bl = cfcolor;
  1451. X        rg.x.cx = NCOL-ccol;    /* Number of characters to write */
  1452. X        int86(0x49, &rg, &rg);
  1453. X
  1454. X}
  1455. X
  1456. Xtiputc(ch)      /* put a character at the current position in the
  1457. X                   current colors */
  1458. X
  1459. Xint ch;
  1460. X
  1461. X{
  1462. X        rg.h.ah = 0x0E;         /* write char to screen with current attrs */
  1463. X        rg.h.al = ch;
  1464. X        int86(0x49, &rg, &rg);
  1465. X}
  1466. X
  1467. Xtieeop()                        /* Actually a clear screen */
  1468. X{
  1469. X
  1470. X        rg.h.ah = 0x13;         /* Clear Text Screen and Home Cursor */
  1471. X        int86(0x49, &rg, &rg);
  1472. X}
  1473. X
  1474. Xtirev(state)            /* change reverse video state */
  1475. X
  1476. Xint state;      /* TRUE = reverse, FALSE = normal */
  1477. X
  1478. X{
  1479. X        setatt( state ? cbcolor : cfcolor  );
  1480. X}
  1481. X
  1482. Xticres()    /* change screen resolution */
  1483. X
  1484. X{
  1485. X    return(TRUE);
  1486. X}
  1487. X
  1488. Xtibeep()
  1489. X{
  1490. X        bdos(6, BEL, 0);
  1491. X}
  1492. X
  1493. Xtiopen()
  1494. X{
  1495. X    strcpy(sres, "NORMAL");
  1496. X        revexist = TRUE;
  1497. X        ttopen();
  1498. X}
  1499. X
  1500. Xticlose()
  1501. X
  1502. X{
  1503. X#if     COLOR
  1504. X        tifcol(7);
  1505. X        tibcol(0);
  1506. X#endif
  1507. X        ttclose();
  1508. X}
  1509. X#else
  1510. Xtihello()
  1511. X{
  1512. X}
  1513. X#endif
  1514. X
  1515. END_OF_tipc.c
  1516. if test 5241 -ne `wc -c <tipc.c`; then
  1517.     echo shar: \"tipc.c\" unpacked with wrong size!
  1518. fi
  1519. # end of overwriting check
  1520. fi
  1521. echo shar: Extracting \"vmsvt.c\" \(6331 characters\)
  1522. if test -f vmsvt.c ; then 
  1523.   echo shar: Will not over-write existing file \"vmsvt.c\"
  1524. else
  1525. sed "s/^X//" >vmsvt.c <<'END_OF_vmsvt.c'
  1526. X/*
  1527. X *  VMS terminal handling routines
  1528. X *
  1529. X *  Known types are:
  1530. X *    VT52, VT100, and UNKNOWN (which is defined to be an ADM3a)
  1531. X *    written by Curtis Smith
  1532. X */
  1533. X
  1534. X#include        <stdio.h>
  1535. X#include        "estruct.h"
  1536. X#include    "edef.h"
  1537. X
  1538. X#if     VMSVT
  1539. X
  1540. X#define    termdef    1            /* don't define "term" external */
  1541. X
  1542. X#include <ssdef.h>        /* Status code definitions        */
  1543. X#include <descrip.h>        /* Descriptor structures        */
  1544. X#include <iodef.h>        /* IO commands                */
  1545. X#include <ttdef.h>        /* tty commands                */
  1546. X
  1547. Xextern  int     ttopen();               /* Forward references.          */
  1548. Xextern  int     ttgetc();
  1549. Xextern  int     ttputc();
  1550. Xextern  int     ttflush();
  1551. Xextern  int     ttclose();
  1552. Xextern  int    vmsopen();
  1553. Xextern    int    vmskopen();
  1554. Xextern    int    vmskclose();
  1555. Xextern  int    vmseeol();
  1556. Xextern  int    vmseeop();
  1557. Xextern  int    vmsbeep();
  1558. Xextern  int    vmsmove();
  1559. Xextern    int    vmsrev();
  1560. Xextern    int    vmscres();
  1561. Xextern  int    eolexist;
  1562. X#if    COLOR
  1563. Xextern    int    vmsfcol();
  1564. Xextern    int    vmsbcol();
  1565. X#endif
  1566. X
  1567. X#define    NROWS    24            /* # of screen rolls        */
  1568. X#define    NCOLS    80            /* # of screen columns        */
  1569. X#define    MARGIN    8            /* size of minimim margin and    */
  1570. X#define    SCRSIZ    64            /* scroll size for extended lines */
  1571. X#define    NPAUSE    100            /* # times thru update to pause */
  1572. X
  1573. X/*
  1574. X * Dispatch table. All the
  1575. X * hard fields just point into the
  1576. X * terminal I/O code.
  1577. X */
  1578. XTERM    term    = {
  1579. X    NROWS - 1,
  1580. X    NROWS - 1,
  1581. X    NCOLS,
  1582. X    NCOLS,
  1583. X    MARGIN,
  1584. X    SCRSIZ,
  1585. X    NPAUSE,
  1586. X        &vmsopen,
  1587. X        &ttclose,
  1588. X    &vmskopen,
  1589. X    &vmskclose,
  1590. X        &ttgetc,
  1591. X        &ttputc,
  1592. X        &ttflush,
  1593. X        &vmsmove,
  1594. X        &vmseeol,
  1595. X        &vmseeop,
  1596. X        &vmsbeep,
  1597. X        &vmsrev,
  1598. X        &vmscres
  1599. X#if    COLOR
  1600. X    , &vmsfcol,
  1601. X    &vmsbcol
  1602. X#endif
  1603. X};
  1604. X
  1605. Xchar * termeop;            /* Erase to end of page string        */
  1606. Xint eoppad;            /* Number of pad characters after eop    */
  1607. Xchar * termeol;            /* Erase to end of line string        */
  1608. Xint eolpad;            /* Number of pad characters after eol    */
  1609. Xchar termtype;            /* Terminal type identifier        */
  1610. X
  1611. X
  1612. X/*******
  1613. X *  ttputs - Send a string to ttputc
  1614. X *******/
  1615. X
  1616. Xttputs(string)
  1617. Xchar * string;
  1618. X{
  1619. X    while (*string != '\0')
  1620. X        ttputc(*string++);
  1621. X}
  1622. X
  1623. X
  1624. X/*******
  1625. X *  vmspad - Pad the output after an escape sequence
  1626. X *******/
  1627. X
  1628. Xvmspad(count)
  1629. Xint count;
  1630. X{
  1631. X    while (count-- > 0)
  1632. X        ttputc('\0');
  1633. X}
  1634. X
  1635. X
  1636. X/*******
  1637. X *  vmsmove - Move the cursor
  1638. X *******/
  1639. X
  1640. Xvmsmove(row, col)
  1641. X{
  1642. X    switch (termtype) {
  1643. X        case TT$_UNKNOWN:
  1644. X            ttputc('\033');
  1645. X            ttputc('=');
  1646. X            ttputc(row+' ');
  1647. X            ttputc(col+' ');
  1648. X            break;
  1649. X        case TT$_VT52:
  1650. X            ttputc('\033');
  1651. X            ttputc('Y');
  1652. X            ttputc(row+' ');
  1653. X            ttputc(col+' ');
  1654. X            break;
  1655. X                case TT$_VT100:         /* I'm assuming that all these  */
  1656. X                case TT$_VT101:         /* are a super set of the VT100 */
  1657. X                case TT$_VT102:         /* If I'm wrong, just remove    */
  1658. X                case TT$_VT105:         /* those entries that aren't.   */
  1659. X                case TT$_VT125:
  1660. X                case TT$_VT131:
  1661. X                case TT$_VT132:
  1662. X                case TT$_VT200_SERIES:
  1663. X            {
  1664. X                char buffer[24];
  1665. X
  1666. X                sprintf(buffer, "\033[%d;%dH", row+1, col+1);
  1667. X                ttputs(buffer);
  1668. X                vmspad(50);
  1669. X            }
  1670. X    }
  1671. X}
  1672. X
  1673. X/*******
  1674. X *  vmsrev - set the reverse video status
  1675. X *******/
  1676. X
  1677. Xvmsrev(status)
  1678. X
  1679. Xint status;    /* TRUE = reverse video, FALSE = normal video */
  1680. X{
  1681. X    switch (termtype) {
  1682. X        case TT$_UNKNOWN:
  1683. X            break;
  1684. X        case TT$_VT52:
  1685. X            break;
  1686. X        case TT$_VT100:
  1687. X            if (status) {
  1688. X                ttputc('\033');
  1689. X                ttputc('[');
  1690. X                ttputc('7');
  1691. X                ttputc('m');
  1692. X            } else {
  1693. X                ttputc('\033');
  1694. X                ttputc('[');
  1695. X                ttputc('m');
  1696. X            }
  1697. X            break;
  1698. X    }
  1699. X}
  1700. X
  1701. X/*******
  1702. X *  vmscres - Change screen resolution (which it doesn't)
  1703. X *******/
  1704. X
  1705. Xvmscres()
  1706. X
  1707. X{
  1708. X    return(TRUE);
  1709. X}
  1710. X
  1711. X#if    COLOR
  1712. X/*******
  1713. X *  vmsfcol - Set the forground color (not implimented)
  1714. X *******/
  1715. Xvmsfcol()
  1716. X{
  1717. X}
  1718. X
  1719. X/*******
  1720. X *  vmsbcol - Set the background color (not implimented)
  1721. X *******/
  1722. Xvmsbcol()
  1723. X{
  1724. X}
  1725. X#endif
  1726. X
  1727. X/*******
  1728. X *  vmseeol - Erase to end of line
  1729. X *******/
  1730. X
  1731. Xvmseeol()
  1732. X{
  1733. X    ttputs(termeol);
  1734. X    vmspad(eolpad);
  1735. X}
  1736. X
  1737. X
  1738. X/*******
  1739. X *  vmseeop - Erase to end of page (clear screen)
  1740. X *******/
  1741. X
  1742. Xvmseeop()
  1743. X{
  1744. X    ttputs(termeop);
  1745. X    vmspad(eoppad);
  1746. X}
  1747. X
  1748. X
  1749. X/*******
  1750. X *  vmsbeep - Ring the bell
  1751. X *******/
  1752. X
  1753. Xvmsbeep()
  1754. X{
  1755. X    ttputc('\007');
  1756. X}
  1757. X
  1758. X
  1759. X/*******
  1760. X *  vmsopen - Get terminal type and open terminal
  1761. X *******/
  1762. X
  1763. Xvmsopen()
  1764. X{
  1765. X    termtype = vmsgtty();
  1766. X    switch (termtype) {
  1767. X        case TT$_UNKNOWN:    /* Assume ADM3a    */
  1768. X            eolexist = FALSE;
  1769. X            termeop = "\032";
  1770. X            eoppad = 0;
  1771. X            break;
  1772. X        case TT$_VT52:
  1773. X            termeol = "\033K";
  1774. X            eolpad = 0;
  1775. X            termeop = "\033H\033J";
  1776. X            eoppad = 0;
  1777. X            break;
  1778. X        case TT$_VT100:
  1779. X            revexist = TRUE;
  1780. X            termeol = "\033[K";
  1781. X            eolpad = 3;
  1782. X            termeop = "\033[;H\033[2J";
  1783. X            eoppad = 50;
  1784. X            break;
  1785. X        default:
  1786. X            puts("Terminal type not supported");
  1787. X            exit (SS$_NORMAL);
  1788. X    }
  1789. X    strcpy(sres, "NORMAL");
  1790. X        ttopen();
  1791. X}
  1792. X
  1793. X
  1794. Xstruct iosb {            /* I/O status block            */
  1795. X    short    i_cond;        /* Condition value            */
  1796. X    short    i_xfer;        /* Transfer count            */
  1797. X    long    i_info;        /* Device information            */
  1798. X};
  1799. X
  1800. Xstruct termchar {        /* Terminal characteristics        */
  1801. X    char    t_class;    /* Terminal class            */
  1802. X    char    t_type;        /* Terminal type            */
  1803. X    short    t_width;    /* Terminal width in characters        */
  1804. X    long    t_mandl;    /* Terminal's mode and length        */
  1805. X    long    t_extend;    /* Extended terminal characteristics    */
  1806. X};
  1807. X
  1808. X/*******
  1809. X *  vmsgtty - Get terminal type from system control block
  1810. X *******/
  1811. X
  1812. Xvmsgtty()
  1813. X{
  1814. X    short fd;
  1815. X    int status;
  1816. X    struct iosb iostatus;
  1817. X    struct termchar tc;
  1818. X    $DESCRIPTOR(devnam, "SYS$INPUT");
  1819. X
  1820. X    status = sys$assign(&devnam, &fd, 0, 0);
  1821. X    if (status != SS$_NORMAL)
  1822. X        exit (status);
  1823. X
  1824. X    status = sys$qiow(        /* Queue and wait        */
  1825. X        0,            /* Wait on event flag zero    */
  1826. X        fd,            /* Channel to input terminal    */
  1827. X        IO$_SENSEMODE,        /* Get current characteristic    */
  1828. X        &iostatus,        /* Status after operation    */
  1829. X        0, 0,            /* No AST service        */
  1830. X        &tc,            /* Terminal characteristics buf    */
  1831. X        sizeof(tc),        /* Size of the buffer        */
  1832. X        0, 0, 0, 0);        /* P3-P6 unused            */
  1833. X
  1834. X                    /* De-assign the input device    */
  1835. X    if (sys$dassgn(fd) != SS$_NORMAL)
  1836. X        exit(status);
  1837. X
  1838. X    if (status != SS$_NORMAL)    /* Jump out if bad status    */
  1839. X        exit(status);
  1840. X    if (iostatus.i_cond != SS$_NORMAL)
  1841. X        exit(iostatus.i_cond);
  1842. X
  1843. X    return tc.t_type;        /* Return terminal type        */
  1844. X}
  1845. X
  1846. Xvmskopen()
  1847. X
  1848. X{
  1849. X}
  1850. X
  1851. Xvmskclose()
  1852. X
  1853. X{
  1854. X}
  1855. X
  1856. X#if    FLABEL
  1857. Xfnclabel(f, n)        /* label a function key */
  1858. X
  1859. Xint f,n;    /* default flag, numeric argument [unused] */
  1860. X
  1861. X{
  1862. X    /* on machines with no function keys...don't bother */
  1863. X    return(TRUE);
  1864. X}
  1865. X#endif
  1866. X#else
  1867. X
  1868. Xhellovms()
  1869. X
  1870. X{
  1871. X}
  1872. X
  1873. X#endif    VMSVT
  1874. END_OF_vmsvt.c
  1875. if test 6331 -ne `wc -c <vmsvt.c`; then
  1876.     echo shar: \"vmsvt.c\" unpacked with wrong size!
  1877. fi
  1878. # end of overwriting check
  1879. fi
  1880. echo shar: End of archive 2 \(of 14\).
  1881. cp /dev/null ark2isdone
  1882. MISSING=""
  1883. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1884.     if test ! -f ark${I}isdone ; then
  1885.     MISSING="${MISSING} ${I}"
  1886.     fi
  1887. done
  1888. if test "${MISSING}" = "" ; then
  1889.     echo You have unpacked all 14 archives.
  1890.     echo "See the readme file"
  1891.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1892. else
  1893.     echo You still need to unpack the following archives:
  1894.     echo "        " ${MISSING}
  1895. fi
  1896. ##  End of shell archive.
  1897. exit 0
  1898.